<?php

/**
 * CalendarEvent form base class.
 *
 * @method CalendarEvent getObject() Returns the current form's model object
 *
 * @package    ecollegeplus
 * @subpackage form
 * @author     Batanayi Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCalendarEventForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'calendar_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Calendar'), 'add_empty' => false)),
      'user_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => false)),
      'name'           => new sfWidgetFormInputText(),
      'location'       => new sfWidgetFormInputText(),
      'from_date'      => new sfWidgetFormDateTime(),
      'to_date'        => new sfWidgetFormDateTime(),
      'reminder'       => new sfWidgetFormInputText(),
      'description'    => new sfWidgetFormTextarea(),
      'is_personal'    => new sfWidgetFormInputCheckbox(),
      'notify_changes' => new sfWidgetFormInputCheckbox(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'calendar_id'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Calendar'))),
      'user_id'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'))),
      'name'           => new sfValidatorString(array('max_length' => 255)),
      'location'       => new sfValidatorString(array('max_length' => 255)),
      'from_date'      => new sfValidatorDateTime(),
      'to_date'        => new sfValidatorDateTime(),
      'reminder'       => new sfValidatorInteger(array('required' => false)),
      'description'    => new sfValidatorString(),
      'is_personal'    => new sfValidatorBoolean(array('required' => false)),
      'notify_changes' => new sfValidatorBoolean(array('required' => false)),
      'created_at'     => new sfValidatorDateTime(),
      'updated_at'     => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('calendar_event[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'CalendarEvent';
  }

}
